package com.example.demo.mapper;

import com.example.demo.pojo.Order;
import com.example.demo.pojo.OrderItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderItemMapper {
	@Insert("INSERT INTO orderItem (orderNum, sellerID, goodsID, goodsName, goodsImg, price, num, totalPrice, createTime) " +
			"VALUES (#{orderNum}, #{sellerID}, #{goodsID}, #{goodsName}, #{goodsImg}, #{price}, #{num}, #{totalPrice}, #{createTime})")
	void insert(OrderItem orderItem);

	@Select("<script>" +
			"SELECT * FROM orderItem " +
			"WHERE orderNum IN " +
			"<foreach item='orderNum' collection='orderNums' open='(' separator=',' close=')'>" +
			"#{orderNum}" +
			"</foreach>" +
			"</script>")
	List<OrderItem> selectOrderItemsByOrderNums(@Param("orderNums") List<String> orderNums);
}
